﻿using LaoLuo;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace LaoLuo.Common.Test
{
    
    
    /// <summary>
    ///这是 CircleTest 的测试类，旨在
    ///包含所有 CircleTest 单元测试
    ///</summary>
    [TestClass()]
    public class CircleTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region 附加测试特性
        // 
        //编写测试时，还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [TestMethod()]
        public void CircleConstructorTest()
        {
            Assert.AreEqual(0, new CircularList<DayOfWeek>().Count);
            Assert.AreEqual(7, new CircularList<DayOfWeek>(new List<DayOfWeek> { DayOfWeek.Sunday, DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday }).Count);
            var c = new CircularList<DayOfWeek>(DayOfWeek.Sunday, DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday);
            Assert.AreEqual(7, c.Count);

            Assert.AreEqual(DayOfWeek.Sunday, c[c.IndexOf(DayOfWeek.Saturday) + 1]);
            Assert.AreEqual(DayOfWeek.Tuesday, c[c.IndexOf(DayOfWeek.Monday) + 1]);
            Assert.AreEqual(DayOfWeek.Monday, c[c.IndexOf(DayOfWeek.Saturday) + 2]);

            c[7] = DayOfWeek.Friday;
            Assert.AreEqual(c[0], c[7]);
            Assert.AreEqual(DayOfWeek.Friday, c[0]);
        }
    }
}
